<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="eduboat.comm.util.ReturnConstant" %>
<%@page import="eduboat.comm.util.SysConstant"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录-数码校园</title>
		<%  
		    //登录成功后返回页面 如果不为空则跳转到返回页面，如果为空则跳转到index.jsp
			String xt_back_uri = (String) request.getAttribute("xt_back_uri");
			if (xt_back_uri == null)
				xt_back_uri = "";
			String xt_hiddenElement = (String) request
					.getAttribute("xt_hiddenElement");
			if (xt_hiddenElement == null)
				xt_hiddenElement = "";

			String path = request.getContextPath();
		%>



<style type="text/css">
<!--

 html,body{height:100%;padding:0;margin:0;}
 #wrap{width:400px;margin:0 auto;border:1px solid #FFFFFF;position:absolute;top:50%;left:50%;margin-left:-200px;}
 

.waitDialog{
background-image:url("loading.gif");
width:32px;
height:32px;


}
-->
</style>

<style>
.massage_box{  filter:dropshadow(color=#666666,offx=5,offy=5,positive=1);} 
 
.massage{border:#036 solid; border-width:3 3 3 3;border-left-style: solid;border-left-width: 1px;border-left-color:#036
border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #036;
border-right-style: solid;border-right-width: 1px;border-right-color: #036;
;width:95%; height:90%; background:#FCFCFC; color:#036; font-size:12px; line-height:150%} 
.header{background:#036; height:10%; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; padding:3 5 0 5; color:#fff} 

</style>
<script type="text/javascript" src="<%=path %>/comm/plug/dialog/artDialog.js?skin=<%=SysConstant.default_xt_skin %>"></script>
<script type="text/javascript" src="<%=path %>/comm/plug/dialog/iframeTools.js"></script>
<script type="text/javascript" src="<%=path %>/comm/js/jquery-1.7.1.min.js"></script>
<script language="javascript" type="text/javascript">

	var xt_back_uri="<%=xt_back_uri%>";
	
	/**
	登录
	**/
   function xt_login(){
   
   var login_id=$("#login_id").val();
   var password=$("#login_pwd").val();
   var savestate=$("#savestate");
   var err="";
   if(login_id=="")
      err+="请输入登录账号!<br/>";
   if(password=="")
      err+="请输入登录密码!<br/>";
    if(err!=""){
    	art.dialog.alert(err,function(){},"error");
        return;
    }    
    if(savestate.attr("checked")){//需要记录登录状态
     setCookie("dsch_login_id",login_id);
     setCookie("dsch_login_pwd",password);
    }else{//删除cookie
     delCookie("dsch_login_id");
     delCookie("dsch_login_pwd");
    }
   var url="<%=path%>/work/admin/xtgl/json/login.action";
   var datas = "loginID="+login_id+"&passWord="+password;
   var dialog = waiting("正在登录，请等待");
   $.post(url,datas,function(data){returnFunction(data,dialog);},"json");
  }



    function returnFunction(data,dialog){ 
      dialog.close();
	   var returnCode = data.returnVO.returnCode;
      if(returnCode=="<%=ReturnConstant.IS_DEAL_OK%>"){//登录成功
    	 checkOk();
      }else if(returnCode=="<%=ReturnConstant.IS_DEAL_FAIL%>"){
        art.dialog.alert(data.returnVO.returnDesc,function(){},"error");
      }else if(returnCode=="<%=ReturnConstant.IS_PARAMS_ERR%>"){
        art.dialog.alert("传入参数不正确",function(){},"error");
      }else if(returnCode=="<%=ReturnConstant.IS_ERR%>"){
        art.dialog.alert("程序异常",function(){},"error");
      }
    }	
 
	/***
	  成功登陆
	  登录成功后返回页面 如果不为空则跳转到返回页面，
	   如果为空则跳转到index.jsp
	**/
	function checkOk(){
	  var url="";
	  if(xt_back_uri==""){
		  url = "<%=path%>/login/go_default_page.jsp";
	  }else{
		  url = xt_back_uri;
	  }
	  document.location.href = url;

	}

	/**
	 设置cookie
	 **/
	function setCookie(name, value)//两个参数，一个是cookie的名子，一个是值
	{
		var Days = 30; //此 cookie 将被保存 30 天
		var exp = new Date(); //new Date("December 31, 9998");
		exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
		document.cookie = name + "=" + escape(value) + ";expires="
				+ exp.toGMTString() + ";path=<%=path%>;";
	}
	/**
	 得到cookie
	 **/
	function getCookie(name)//取cookies函数        
	{
		var arr = document.cookie.match(new RegExp("(^| )" + name
				+ "=([^;]*)(;|$)"));
		if (arr != null)
			return unescape(arr[2]);
		return null;

	}
	/**
	 删除cookie
	 ***/
	function delCookie(name)//删除cookie
	{
		var exp = new Date();
		exp.setTime(exp.getTime() - 1);
		var cval = getCookie(name);		
		if (cval != null){
			document.cookie = name + "=" + cval + ";expires="
					+ exp.toGMTString()+ ";path=<%=path%>;";
			
		}
		
		
	}

	function initCookie() {
		var login_id = $("#login_id");
		var password = $("#login_pwd");
		var savestate = $("#savestate");
		/**
		  delCookie("dsch_login_id");
		  delCookie("dsch_login_pwd");
		 **/
		var dsch_login_id = getCookie("dsch_login_id");
		var dsch_login_pwd = getCookie("dsch_login_pwd");
		if (dsch_login_id != null)
			login_id.val(dsch_login_id);
		if (dsch_login_pwd != null)
			password.val(dsch_login_pwd);
		if (dsch_login_id != null)
			savestate.attr("checked",true);
	}

	function Hotkey(event, targetObj, keycode) {
		if (targetObj && event.keyCode == keycode)
			targetObj.click();
	}
	function fnKeyup(event) {
		var b = $("#login_b");
		Hotkey(event, b, 13);
	}
	// 捕获系统的Keyup事件
	// 如果是Mozilla系列浏览器
	if (document.addEventListener)
		document.addEventListener("keyup", fnKeyup, true);
	else
		document.attachEvent("onkeyup", fnKeyup);
</script>
</head>

<body >

	<div id="wrap" >
	
	<div class="massage_box" style="width:400px;height:200px;  float:left; margin-left:10px">
		   		<div class="massage"> 
		    		<div class="header" >
						<div style="display:inline; width:150px; position:absolute;font-weight:bold">学舟智慧校园-用户登录 </div> 
						<!-- <span onClick="parentElement.parentElement.style.visibility='hidden'; " style="float:right; display:inline; cursor:hand">×
						</span> -->
					</div> 
					<div style="margin-left:10px; margin-right:10px; margin-top:5px">
						<div style="color:red;font-size:12px;width:100%; text-align:center">登录失效，请重新登录!</div>
						<hr/>
						
			  <table border="0" align="center" style="margin-top: 10px;width:100%">
				
				
				<tr>
					<td>登录帐号：</td>
					<td><input type="text" id="login_id" style="width: 150px"/></td>
				</tr>
				<tr>
					<td>登录密码：</td>
					<td><input type="password" id="login_pwd" style="width: 150px"/></td>
				</tr>
				
				<tr>
					<td>&nbsp;</td>
					<td>
						<input type="button" value="登录" id="login_b" onclick="xt_login()"  style="width: 80px"/>
						
						<label style="margin-left: 20px">
						<input type="checkbox"  name="savestate" tabindex="3" id="savestate"/>记住登录状态
						</label>
						
					</td>
				</tr>
			</table>
					</div>
				 </div>
			  </div>
			
	
	</div>
	  <%
	  	if (xt_hiddenElement.length() != 0 && xt_back_uri.length() != 0) {
	  %>
  <form name="xt_backUriForm" action="<%=xt_back_uri%>" method="post">
  <%=xt_hiddenElement%>
  </form>  
  <%
    	}
    %>

	<iframe id='popIframe' class='popIframe' frameborder='0' ></iframe>
	
</body>
</html>
<SCRIPT LANGUAGE="JavaScript">
//垂直居中
function vMiddle(){
    var middleDiv=document.getElementById("wrap");
    var divHeight=middleDiv.offsetHeight;
    var bodyHeight=document.body.offsetHeight ;
 if(bodyHeight>divHeight)
    middleDiv.style.marginTop=-divHeight/2+"px";
 initCookie();//cookie初始化
}

window.onload=vMiddle; //网面打开时时执行moveit()
window.onresize=vMiddle; //当调整浏览器大小时执行moveit()
window.onscroll=vMiddle; //当拉动滚动条时执行moveit()
</SCRIPT> 

